'++++8328_92000
'GCV_FRONT = 2
'GCV_LEFT = 4
'GCV_RIGHT = 5
'GCV_EXTENDED = 7
'GCV_SIMPLIFIED = 8
'GCV_STANDARD = 9
'SIDE = GCV_FRONT

'DETAIL_LEVEL = GCV_STANDARD

hatchAngle  = 45                  
'hatchStep= 2                   

drawFace1 =1

'PAR_din=20
'PAR_d=47
'PAR_b=14
'PAR1_dain= (25+26) * 0.5
'PAR1_da=  42
'PAR1_dw= 6.5
'PAR1_r = 1.5
 
'PAR2_r1 =  1
'PAR2_t1 =  2.45
'PAR2_c1 =  1.3
'PAR2_D1 =  44.6
'PAR2_Lw = 6.5
PAR2_bottomSide = 0 'TRUE

''PAR_AXIS = 1
''PAR_Simpl_AXIS = 1

'++++++++++++++
SUB LINE (x1,y1,x2,y2,t) Doc.ksLineSEG x1,y1,x2,y2,t END SUB
'++++++++++++++

 SUB DrawRoller ( xtr, ytr,  rads,   len,b,  del) 
  LEN1 =LEN* 0.5
  Line -del,ytr,b+del,ytr,3
  Line  xtr - len1, ytr - rads, xtr - len1, ytr + rads, 1 
  Line  xtr - len1, ytr + rads, xtr + len1, ytr + rads, 1 
  Line  xtr + len1, ytr + rads, xtr + len1, ytr - rads, 1 
  Line  xtr + len1, ytr - rads, xtr - len1, ytr - rads, 1 

END SUB
'++++++++++++++
SUB Script_OnLoad ()


   ys=(  PAR_din+ PAR_D)*0.25
   xs= PAR_B*0.5
   rn= PAR_D*0.5
   rv= PAR_din*0.5
   rv2= PAR1_dain*0.5
  ' rb2=  PAR2_bottomSide ?  PAR1_Da*0.5 :  PAR1_da*0.5

   IF PAR2_bottomSide =1 THEN
     RB2 =  PAR1_Da*0.5  
   ELSE 
     RB2 = PAR1_dain*0.5
  END IF

   rn2=  PAR1_Da*0.5
   rR =  PAR1_Dw*0.5 ' //?aaeon oa?eea

'   rfn =  PAR2_bottomSide ?  PAR2_r1 :  PAR1_r

IF PAR2_bottomSide = 1 THEN
     rfn =  PAR2_r1  
   ELSE 
     rfn =  PAR1_r
  END IF

 '  rfv = ! PAR2_bottomSide ?  PAR2_r1 :  PAR1_r

If PAR2_bottomSide <> 1 THEN
     rfv =  PAR2_r1  
   ELSE 
     rfv =  PAR1_r
 End IF


   IF  rv2 < (ys-0.8*rR) THEN 
    rv2 = ys-0.8*rR
   END IF

  IF    PAR2_bottomSide =1 THEN  '   //ai?oia iao ia aiaoiai eieuoa
      IF  rb2 > (rn- PAR2_r1*1.1) THEN
       rb2 = rn- PAR2_r1*1.1
      END IF  
  ELSE 
       IF  rb2 < (rv+ PAR2_r1*1.1) THEN
       rb2 = rv+ PAR2_r1*1.1
       END IF  
END IF

    IF  rn2 > (ys+0.8*rR) THEN
    rn2 = ys+0.8*rR
  'bool flag =false
   h = 0
    IF  PAR_AXIS = 1  THEN
      h = h-PAR_B
      'flag = true
    END IF
    
doc.ksColouring &HFE000000
  Contur rv, rn, rfv, rfn, rfn,  rfv,  PAR_B, -1
  Contur rv, rn, rfv, rfn, rfn,  rfv,  PAR_B, 1
doc.ksEndObj

SELECT CASE DETAIL_LEVEL
      Case GCV_EXTENDED:
DrawOutsideRing  rn,  rn2, rb2,   PAR_B, rfn,rfn,  xs, ys, rR,  PAR2_Lw, 1,PAR2_bottomSide,PAR2_bottomSide  
       DrawRoller      xs,ys, rR,  PAR2_Lw,  PAR_B, 2 
DrawInsideRing   rv,  rv2, rb2,   PAR_B, rfv, rfv,  xs, ys, rR,  PAR2_Lw, 1,0,0

       IF PAR_AXIS <> 1 THEN
          line  0, rn-rfn, 0, rv+rfv, 1 
          line   PAR_B, rn-rfn,  PAR_B, rv+rfv, 1 
        END IF
DrawOutsideRing rn,  rn2, rb2,   PAR_B, rfn,rfn,  xs, ys, rR,  PAR2_Lw, -1, PAR2_bottomSide,  PAR2_bottomSide  
        DrawRoller       xs,-ys, rR,  PAR2_Lw,  PAR_B, 2 
 DrawInsideRing   rv,  rv2, rb2,   PAR_B, rfv, rfv,   xs, ys, rR,  PAR2_Lw, -1,0,0

       IF PAR_AXIS <> 1 THEN
          line  0,-( rn-rfn), 0, -(rv+rfv), 1 
          line   PAR_B, -(rn-rfn),  PAR_B, -(rv+rfv), 1 
        END IF


      case  GCV_STANDARD:
 DrawOutsideRing  rn,  rn2, rb2,   PAR_B, rfn,rfn,  xs, ys, rR,  PAR2_Lw, 1, PAR2_bottomSide,  PAR2_bottomSide  
  DrawRoller       xs,ys, rR,  PAR2_Lw,  PAR_B, 2 
 DrawInsideRing   rv,  rv2, rb2,   PAR_B, rfv, rfv,  xs, ys, rR,  PAR2_Lw, 1,0,0

       IF PAR_AXIS <> 1 THEN
          line  0, rn-rfn, 0, rv+rfv, 1 
          line   PAR_B, rn-rfn,  PAR_B, rv+rfv, 1 
        END IF

        DrawSimple rv, rn, rfv, rfn, rfn,  rfv,  PAR_B, -1
CASE GCV_SIMPLIFIED:
       DrawSimple rv, rn, rfv, rfn, rfn,  rfv,  PAR_B, 1
       DrawSimple rv, rn, rfv, rfn, rfn,  rfv,  PAR_B, -1

    END SELECT
END IF
END SUB
'++++++++++++++++++

 SUB DrawInsideRing (  rv,   rv2,  rb,  b,rL,  rR,  xs,  ys, rads,  len, ky, leftSide, rightSide  ) 
Len2 =LEN*0.5
 yR=(rv+rR)*ky
 yL=(rv+rL)*ky
' yRight = rightSide ? rb*ky : rv2*ky;
IF rightSide=1 THEN 
yRight = rb*ky
ELSE
yRight = rv2*ky
 END IF

 'yLeft  = leftSide  ? rb*ky : rv2*ky;

IF leftSide =1 THEN 
yLeft  = rb*ky
ELSE
yLeft  = rv2*ky
 END IF

rR1=PAR2_r1
delta= rR- rR1

   doc.ksArcByPoint rL,yL,rL,0,yL,rL,rv*ky,ky,1
    line rL,rv*ky,b-rR1,rv*ky,1
   doc.ksArcByPoint b-rR1,(abs(yR)-delta)*ky,rR1,b-rR1,rv*ky,b, (abs(yR)-delta)*ky,ky,1
  IF  rightSide =1 THEN
    Line  b, yRight, xs+ Len2, (ys-rads)*ky, 1 
  ELSE
    Line  b, yRight, xs+ Len2, yRight, 1 
END IF

  IF  leftSide =1 THEN
    line  xs- Len2, (ys-rads)*ky, 0, yLeft, 1
 ELSE 
    Line   xs- Len2, yLeft, 0, yLeft, 1 
  END IF

Doc.kshatch  0, hatchAngle -90, hatchStep, 0, 0, 0   
      doc.ksArcByPoint rL,yL,rL,0,yL,rL,rv*ky,ky,1
     line rL,rv*ky, xs+ Len2,rv*ky,1
     line  xs+ Len2,rv*ky, xs+ Len2, (ys-rads)*ky, 1 
     Line  xs+ Len2, (ys-rads)*ky, xs- Len2, (ys-rads)*ky, 1 

     IF  leftSide =1 THEN 
       line  xs- Len2, (ys-rads)*ky, 0, yLeft, 1 
     ELSE  
       Line   xs- Len2, (ys-rads)*ky, xs-len2, yLeft, 1 
       Line   xs-len2, yLeft, 0, yLeft, 1 
     END IF
     Line   0, yLeft, 0,yL, 1 

Doc.ksEndObj



Doc.kshatch  0, hatchAngle, hatchStep/2, 0, 0, 0   
     line xs+ Len2,rv*ky,b-rR,rv*ky,1
      doc.ksArcByPoint b-rR,yR,rR,b-rR,rv*ky,b,yR,ky,1
     line  b,yR, b, yRight, 1 
       line b, yRight, xs+ Len2, yRight, 1 
       line xs+ Len2, yRight, xs+ Len2, rv*ky, 1 


Doc.ksEndObj


 IF PAR_AXIS = 1 THEN
    Line rL,rv*ky,rL,0,1
    Line b-rR1,rv*ky,b-rR1,0,1
    Line xs+ Len2, (ys-rads)*ky, xs+ Len2,0, 1
  Else 
   Line xs+ Len2, (ys-rads)*ky, xs+ Len2,rv*ky, 1
  END IF



END SUB
'++++++++++++++++++++++
SUB DrawOutsideRing  ( rn,   rn2,  rb,  b, rL,  rR,  xs,  ys,rads,  len,ky,leftSide ,rightSide  ) 
LEN3=LEN* 0.5
 yL=(rn-rL)*ky '  //neaaa
 yR=(rn-rR)*ky'
' yRight = rightSide ? rb*ky : rn2*ky;
IF rightSide=1 THEN 
yRight = rb*ky
ELSE
yRight = rn2*ky
 END IF

 'yLeft  = leftSide  ? rb*ky : rn2*ky;
IF leftSide =1 THEN 
yLeft = rb*ky
ELSE
yLeft = rn2*ky
 END IF

  doc.ksArcByPoint rL,yL,rL,0,yL,rL,rn*ky,-ky,1
  line rL,rn*ky,b-rR,rn*ky,1
  doc.ksArcByPoint b-rR,yR,rR,b-rR,rn*ky,b,yR,-ky,1
  IF rightSide=1 THEN 
    Line  b, yRight, xs+ LEN3, (ys+rads)*ky, 1 
  ELSE
    Line  b, yRight, xs+ LEN3, yLeft, 1 
END IF
 IF  leftSide =1 THEN
    Line   xs- LEN3, (ys+rads)*ky, 0, yLeft, 1 
 ELSE
    Line   xs- LEN3, yLeft, 0, yLeft, 1 
END IF

  Doc.kshatch  0,hatchAngle,hatchStep,0,0,0
     doc.ksArcByPoint rL,yL,rL,0,yL,rL,rn*ky,-ky,1
     line rL,rn*ky,b-rR,rn*ky,1
     doc.ksArcByPoint b-rR,yR,rR,b-rR,rn*ky,b,yR,-ky,1
     line  b,yR, b, yRight, 1 
      IF  rightSide THEN
       Line  b, yRight, xs+ LEN3, (ys+rads)*ky, 1 
     ELSE 
       Line  b, yRight, xs+ LEN3, yRight, 1
       Line  xs+ LEN3, yRight, xs+ LEN3, (ys+rads)*ky, 1 
     END IF
     Line  xs+ LEN3, (ys+rads)*ky, xs- LEN3, (ys+rads)*ky, 1 

     IF   leftSide =1 THEN
       Line   xs- LEN3, (ys+rads)*ky, 0, yLeft, 1 
     ELSE  
       Line   xs- LEN3, (ys+rads)*ky, xs- LEN3, yLeft, 1 
       Line   xs- LEN3, yLeft, 0, yLeft, 1 
     END IF
     Line   0, yLeft, 0,yL, 1 

Doc.ksEndObj

IF PAR_AXIS = 1 THEN
   Line b,yR,b,0,1
   Line 0,yL,0,0,1
   IF   ky = 1 THEN
     Line  -2, 0, b+2, 0, 3 
    END IF
 END IF
END SUB
 '+++++++++++++++++++++
sub DrawSimple (rv, rn, rf1, rf2,rf3, rf4, b,  ky) 

rR1=PAR2_r1
delta= rf4- rR1

 x1=rf1
 x2=rf2
 x3=b-rf3
 x4=b-rf4

 y1=(rv+rf1)*ky
 y2=(rn-rf2)*ky
 y3=(rn-rf3)*ky
 y4=(rv+rf4)*ky

  if  drawFace1=1 then
    line 0,y1,0,y2,1
end if

  doc.ksArcByPoint x2,y2,rf2,0,y2,x2,rn*ky,-ky,1 ';  /*5*/
  line x2,rn*ky,x3,rn*ky,1
  doc.ksArcByPoint x3,y3,rf3,x3,rn*ky,b,y3,-ky,1 ' ; /*6*/
  line b,y3,b,y4,1
 doc.ksArcByPoint x4+delta,y4-delta*ky,rR1,b, y4-delta*ky,x4+delta,rv*ky,-ky,1 '; /*7*/
  line x4+delta,rv*ky,x1,rv*ky,1
  doc.ksArcByPoint x1,y1,rf1,x1,rv*ky,0,y1,-ky,1 ';     /*8*/

  If PAR_Simpl_AXIS = 1 Then 
  line x1,y1,x3,y3,2
  line x2,y2,x4,y4,2
 ''NEW 
 Else 
   Line b/3,(rn+rv)*0.5*ky,2*b/3,(rn+rv)*0.5*ky,2
   Line b*0.5,((rn+rv)*0.5-b/6)*ky,b*0.5,((rn+rv)*0.5+b/6)*ky,2
   ''
 End If   
  if PAR_AXIS = 1 THEN  
    line b,0,b,y4,1
    line x1,0,x1,rv*ky,1
    line x4+delta,0,x4+delta,rv*ky,1

line (b+ PAR2_Lw)/2,rv*ky, (b+ PAR2_Lw)/2,0,1

    if  drawFace1 =1 then
      line 0,y1,0,0,1
   end if
     if ky = 1  then
      line -2, 0, b+2, 0, 3
end if
  end if
end sub
'+++++++++++++++
Sub Contur (rv, rn, rf1, rf2,rf3, rf4, b,ky) 

 x1=rf1
 x2=rf2
 x3=b-rf3
 x4=b-rf4

 y1=(rv+rf1)*ky
 y2=(rn-rf2)*ky
 y3=(rn-rf3)*ky
 y4=(rv+rf4)*ky


  line 0,y1,0,y2,1
  doc.ksArcByPoint x2,y2,rf2,0,y2,x2,rn*ky,-ky,1 ';  /*5*/
  line x2,rn*ky,x3,rn*ky,1
  doc.ksArcByPoint x3,y3,rf3,x3,rn*ky,b,y3,-ky,1 ' ; /*6*/
  line b,y3,b,y4,1
  line 0,y1,0,0,1
  line b,0,b,y4,1

End Sub
